<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       const p1 =  new Promise((resolve,reject)=>{
            try{
                console.log('开始打印a数据');
                throw new Error('获取错误')
                setTimeout(()=>{
                    console.log('a数据获取成功');
                    resolve('a数据')
                },1000)
            }catch(e){
                reject(e)
            }
        })

        const p2 =  new Promise((resolve,reject)=>{
            try{
                console.log('开始打印b数据');
                throw new Error('获取错误')

                setTimeout(()=>{
                    console.log('b数据获取成功');
                    resolve('b数据')
                },2000)
            }catch(e){
                reject(e)
            }
        })

        const p3 =  new Promise((resolve,reject)=>{
            try{
                console.log('开始打印c数据');
                throw new Error('获取错误')

                setTimeout(()=>{
                    console.log('c数据获取成功');
                    resolve('c数据')
                },2500)
            }catch(e){
                reject(e)
            }
        })

        const result = Promise.any([p1,p2,p3]);
        console.log('result',result);
        
        // 返回一个成功的promise,值是最快更改状态的那个,如果最快的状态失败,则是第二个最快的
        //如果全部失败,则返回一个失败的promise.值是新的错误信息AggregateError


    </script>
</body>
</html>